<?php
	class mysql extends PDO
	{
		public $count = 0;
		private $statement = null, $_init = false;

		public function __construct($dsn, $user, $pass)
		{
			parent::__construct($dsn, $user, $pass);
			$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		}
		
		public function query($query, $vars = null)
		{
			if ( $this->_init === false )
			{
				$this->_init = true;				
				$this->query('SET NAMES UTF8');
				$this->count = 0;
			}

			$this->count += 1;
			
			$this->statement = parent::prepare($query);
			$this->statement->execute($vars);
		}
		
		public function num()
		{
			if ( isset($this->statement) && !empty($this->statement) )
			{
				return $this->statement->rowCount();
			}
			
			return false;
		}
		
		public function fetch()
		{
			if ( isset($this->statement) && !empty($this->statement) )
			{
				return $this->statement->fetch();
			}
			
			return false;
		}
	}